<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v3计算属性</title>
  </head>
  <body>
    <div id="app">
      <div>
        {{count}}
        <button @click="count++">+1</button>
        <div>{{doublecountFn()}} - {{doublecountFn()}}</div>
        <div>{{doubleCount}} - {{doubleCount}} -{{doubleCount}}</div>
      </div>
    </div>
    <script src="../lib/vue.global.js"></script>

    <script>
      Vue.createApp({
        data() {
          return {
            count: 0,
            dbCount: 0,
          };
        },

        computed: {
          doubleCount() {
            console.log("doubleCount");
            return this.count * 2;
          },
        },

        methods: {
          doublecountFn() {
            console.log("methods");
            this.dbCount = this.count * 2;
            return this.dbCount;
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
